import request from '@/utils/request'
import axios from 'axios'
export default {
  // 1 添加视频
  addVideo(video) {
    return request({
      url: '/itservice/videoadmin/addVideo',
      method: 'post',
      data: video
    })
  },

  // 2 通过id删除视频
  deleteVideoById(videoId) {
    return request({
      url: `/itservice/videoadmin/deleteVideoById/${videoId}`,
      method: 'delete'
    })
  },

  // 3 修改视频
  updateVideo(video) {
    return request({
      url: '/itservice/videoadmin/updateVideo',
      method: 'post',
      data: video
    })
  },

  // 4 根据id查询视频信息
  getVideoInfoById(videoId) {
    return request({
      url: `/itservice/videoadmin/getVideoById/${videoId}`,
      method: 'get'
    })
  },

  // 5 获取视频签名
  getSign() {
    return request({
      url: '/itservice/videoadmin/getSign',
      method: 'get'
    })
  },

  // 6 分页获取视频
  getPageVideo(page, limit) {
    return request({
      url: `/itservice/videoadmin/pageVideo/${page}/${limit}`,
      method: 'get'
    })
  },

  // 7 上传封面
  updateVideoCover(video) {
    return request({
      url: '/itservice/videoadmin/updateVideoCover',
      method: 'post',
      data: video
    })
  },

  // 8 从腾讯云删除视频
  removeTencentVideo(fileId) {
    return request({
      url: `/itservice/videoadmin/removeTencentVideo/${fileId}`,
      method: 'delete'
    })
  },

  //7 更改轮播图状态
  changeState(videoId) {
    return request({
      url: `/itservice/videoadmin/changeState/${videoId}`,
      method: 'get'
    })
  },

  //8 一键更改视频状态
  batchChangeVideoState(state) {
    return request({
      url: `/itservice/videoadmin/batchChangeVideoState/${state}`,
      method: 'get'
    })
  }
}

function getSignature() {
  return axios.get('/itservice/videoadmin/getSign').then(function(response) {
    return response.data.signature
  })
}
